package day20.enumerate;

/**
 * 季节枚举示例
 * 演示枚举在实际开发中的应用，包括抽象方法在枚举中的使用
 */
public class SeasonTest {
    /**
     * 程序入口点
     * @param args 命令行参数
     */
    public static void main(String[] args) {
        // 遍历所有季节并显示信息
        System.out.println("=== 季节信息测试 ===");
        for (Season season : Season.values()) {
            System.out.println("季节: " + season);
            System.out.println("  描述: " + season.getDescription());
            System.out.println("  平均温度: " + season.getAverageTemperature());
            System.out.println("  活动建议: " + season.getActivitySuggestion());
            System.out.println();
        }
        
        // 测试当前季节
        Season currentSeason = Season.SPRING;
        System.out.println("当前季节: " + currentSeason);
        System.out.println("推荐活动: " + currentSeason.getActivitySuggestion());
        
        // 测试枚举比较
        System.out.println("SPRING == SUMMER: " + (Season.SPRING == Season.SUMMER));
        System.out.println("SPRING.getClass(): " + Season.SPRING.getClass());
    }
}

/**
 * 季节枚举
 * 展示带有抽象方法的枚举示例
 */
enum Season {
    // 每个枚举常量都实现抽象方法
    SPRING("春季") {
        @Override
        public String getDescription() {
            return "万物复苏的季节，气温回暖";
        }
        
        @Override
        public int getAverageTemperature() {
            return 15;
        }
        
        @Override
        public String getActivitySuggestion() {
            return "适合踏青、植树、放风筝";
        }
    },
    
    SUMMER("夏季") {
        @Override
        public String getDescription() {
            return "炎热的季节，阳光充足";
        }
        
        @Override
        public int getAverageTemperature() {
            return 28;
        }
        
        @Override
        public String getActivitySuggestion() {
            return "适合游泳、吃冰淇淋、海边度假";
        }
    },
    
    AUTUMN("秋季") {
        @Override
        public String getDescription() {
            return "收获的季节，天高气爽";
        }
        
        @Override
        public int getAverageTemperature() {
            return 18;
        }
        
        @Override
        public String getActivitySuggestion() {
            return "适合登山、赏红叶、采摘";
        }
    },
    
    WINTER("冬季") {
        @Override
        public String getDescription() {
            return "寒冷的季节，雪花纷飞";
        }
        
        @Override
        public int getAverageTemperature() {
            return 2;
        }
        
        @Override
        public String getActivitySuggestion() {
            return "适合滑雪、泡温泉、吃火锅";
        }
    };
    
    // 枚举字段
    private final String name;
    
    /**
     * 枚举构造函数
     * @param name 季节名称
     */
    private Season(String name) {
        this.name = name;
    }
    
    /**
     * 获取季节名称
     * @return 季节名称
     */
    public String getName() {
        return name;
    }
    
    // 抽象方法，每个枚举常量必须实现
    public abstract String getDescription();
    public abstract int getAverageTemperature();
    public abstract String getActivitySuggestion();
    
    /**
     * 重写toString方法，返回季节名称
     * @return 季节名称
     */
    @Override
    public String toString() {
        return name;
    }
}